#include <QtGlobal>
#include <QDesktopServices>
#include "Core.h"



Core::Core(QObject *parent) :
    QThread(parent)
{
}

void Core::CheckDatabase()
{
    QStringList accountsList = set.AccountsList();

    QStringList databaseList = db.GetDatabaseList();
    for(int i=0;i<accountsList.size();i++)
    {
        if(!databaseList.contains(accountsList.at(i) + ".db"))
        {
            CreateDatabase(accountsList.at(i));
        }
    }

    // This is removing of database accounts

    /*databaseList = databaseList + accountsList;
    databaseList.removeDuplicates();
    for(int i=0;i<databaseList.size();i++)
    {
        if(db.DeleteDatabase(databaseList.at(i)))
            qDebug("Delete database");
    }*/
}

void Core::CreateDatabase(QString account)
{
    db.CreateDatabase(account);
}

void Core::DeleteDatabase(QString account)
{
    if(db.DeleteDatabase(account))
        qDebug("Delete database");
    else
        qDebug("Fail to delete database");

}
